jQuery(document).ready(function($){
	
	  function setCookie(value){
		    document.cookie = "buzzr_view="+escape(value);
		  }
		 
		  function getCookie(c_name){
		    var i,x,y,ARRcookies=document.cookie.split(";");
		    for (i=0;i<ARRcookies.length;i++){
		      x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
		      y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
		      x=x.replace(/^\s+|\s+$/g,"");
		      if (x==c_name){
		        return unescape(y);
		      }
		    }
		  }
		 
		  var view = getCookie('buzzr_view');
		 
		  if(view == "grid"){
		    $('#list_wrap ul').removeClass('list').addClass('grid');
		    $('.images').removeClass('fleft');
		  }else if(view == "list"){
		    $('#list_wrap ul').removeClass('grid').addClass('list');
		    $('.images').removeClass('fleft');
		  }
		 
		  $('a').click(function(e) {
		    if ($(this).hasClass('grid')) {
		      setCookie("grid");
		      $('#list_wrap ul').removeClass('list').addClass('grid');
		      $('.images').removeClass('fleft');
		    }
		    else if($(this).hasClass('list')) {
		      setCookie("list");
		      $('#list_wrap ul').removeClass('grid').addClass('list');
		      $('.images').addClass('fleft');
		    }
		  });
    
    $('.social').css('display','none');
    
    $('.deal').mouseenter(function(){
    	$('.social',$(this)).css('display','block');
        $('.info',$(this)).css('background-color','#2589BC');
        $('.info_name',$(this)).css('color','#ffffff');
        $('.info_name a',$(this)).css('color','#ffffff');
    }).mouseleave(function(){
      $('.social',$(this)).css('display','none');
      $('.info',$(this)).css('background-color','#ffffff');
      $('.info_name',$(this)).css('color','#000000');
      $('.info_name a',$(this)).css('color','#000000');
    });
    
    $('.details').hide();
   
    $('.more').click(function(){
    	$(this).parent('.get_deal').siblings('.details').slideToggle(500);
    });
   
    $('.save').click(function(){
    	var id = $(this).attr('id');
    	var splitted = id.split('_');
    	var deal_id = splitted[0]; 
    	var user_id = splitted[1];
    	$.ajax({ 
    	  	type: "post", 
    	  	url: "http://buzzr.in/wp-content/plugins/buzzr_ajax_vote/vote.php",
    	  	data: "deal_id="+deal_id+"&consumer_id="+user_id,
    	  	success: function(msg){
    			$('#result_'+deal_id).html(msg);
    		}
    	});
    });
});